home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / winterp-1.13 / examples / popen.lsp < prev    next >
Encoding:
Lisp/Scheme  |  1991-10-06  |  2.5 KB  |  80 lines

  1. ; -*-Lisp-*-
  2. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3. ;
  4. ; File:         popen.lsp
  5. ; RCS:          $Header: popen.lsp,v 1.3 91/10/05 18:33:42 mayer Exp $
  6. ; Description:  Play around with  POPEN to collect unix data.
  7. ; Author:       Niels Mayer, HPLabs
  8. ; Created:      Sat Nov 25 01:51:55 1989
  9. ; Modified:     Sat Oct  5 18:33:26 1991 (Niels Mayer) mayer@hplnpm
  10. ; Language:     Lisp
  11. ; Package:      N/A
  12. ; Status:       X11r5 contrib tape release
  13. ;
  14. ; WINTERP Copyright 1989, 1990, 1991 Hewlett-Packard Company (by Niels Mayer).
  15. ; XLISP version 2.1, Copyright (c) 1989, by David Betz.
  16. ;
  17. ; Permission to use, copy, modify, distribute, and sell this software and its
  18. ; documentation for any purpose is hereby granted without fee, provided that
  19. ; the above copyright notice appear in all copies and that both that
  20. ; copyright notice and this permission notice appear in supporting
  21. ; documentation, and that the name of Hewlett-Packard and Niels Mayer not be
  22. ; used in advertising or publicity pertaining to distribution of the software
  23. ; without specific, written prior permission.  Hewlett-Packard and Niels Mayer
  24. ; makes no representations about the suitability of this software for any
  25. ; purpose.  It is provided "as is" without express or implied warranty.
  26. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  27.  
  28.  
  29. (defun ls (dirname)
  30.   (do* 
  31.    ((fp (popen (strcat "/bin/ls -1 -r " dirname) :direction :input))
  32.     (line (read-line fp) (read-line fp))
  33.     (result (list line) (cons line result))
  34.     )
  35.    ((null line)
  36.     (pclose fp)
  37.     (cdr result)
  38.     )
  39.    )
  40.   )
  41.  
  42. (defun vls (dirname)
  43.   (do* 
  44.    ((top_w (send TOP_LEVEL_SHELL_WIDGET_CLASS :new
  45.          :XMN_GEOMETRY "500x500+0+0"
  46.          ))
  47.     (rc_w (send XM_ROW_COLUMN_WIDGET_CLASS :new :managed top_w
  48.         :XMN_ADJUST_LAST nil
  49.         ))
  50.     (fp (popen (strcat "/bin/ls -1 -r " dirname) :direction :input))
  51.     (line (read-line fp) (read-line fp))
  52.     )
  53.    ((null line)
  54.     (pclose fp)
  55.     (send top_w :realize)
  56.     )
  57.    (send (send XM_PUSH_BUTTON_GADGET_CLASS :new :managed rc_w
  58.            :XMN_LABEL_STRING line)
  59.      :add_callback :XMN_ACTIVATE_CALLBACK '()
  60.      `((system (strcat "$EDITOR " ,dirname "/" ,line))))
  61.    )
  62.   )
  63.  
  64. (defun mh-scan (foldername msgs)
  65.   (do* 
  66.    ((fp (popen (strcat "scan -reverse +" foldername " " msgs) 
  67.            :direction :input))
  68.     (line (read-line fp) (read-line fp))
  69.     (result (list line) (cons line result))
  70.     )
  71.    ((null line)
  72.     (pclose fp)
  73.     (cdr result)
  74.     )
  75.    )
  76.   )
  77.  
  78. (mh-scan "inbox" "all")
  79. (vls "/users/mayer")
  80.